<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('选择承办单位')"/>
    <link th:href="@{/ajax/libs/bootstrap-tagsinput/tagsinput.css}" rel="stylesheet">
    <link th:href="@{/ajax/libs/jQuery-ui/jquery-ui.css}" rel="stylesheet">
    <script type="text/javascript">
        function run(){
            document.getElementById("tab1").click();
        }
    </script>
    <style>
        label {
            font-weight: bold;
        }

        @font-face {
            font-family: 'huawen';
            src: url("/fonts/huawen.woff2");
        }
    </style>
</head>

<body onload="run()" style="background-color: #F4F6FA;font-size: 13px;font-family:'huawen' ;font-weight: bold">
<div class="main-content" style="margin: 0;padding: 0">

    <form id="form-user-add" class="form-horizontal" style="background-color: #F4F6FA">
        <div class="col-sm-12 entering-page" style="display: flex">
                <div class="col-sm-9" style="margin: 5px;padding-left:0;padding-right:0;">
                    <ul class="nav nav-tabs">
                        <li><a data-toggle="tab" id="tab1" href="#menu1">市级部门</a></li>
                        <li><a data-toggle="tab" id="tab2" href="#menu2">区(市)县</a></li>
<!--                        <li><a data-toggle="tab" id="tab3" href="#menu3">直派(工商)</a></li>-->
<!--                        <li><a data-toggle="tab" id="tab4" href="#menu3">直派(食药监)</a></li>-->
<!--                        <li><a data-toggle="tab" id="tab5" href="#menu5">直派(城管)</a></li>-->
<!--                        <li><a data-toggle="tab" id="tab6" href="#menu6">直派(旅游)</a></li>-->
                    </ul>

                    <div class="tab-content">
                        <div id="menu1" class="tab-pane fade deptTransfer-content">

                        </div>
                        <div id="menu2" class="tab-pane fade deptTransfer-content">

                        </div>
<!--                        <div id="menu3" class="tab-pane fade deptTransfer-content">-->
<!--                            <ul class="deptTransfer-ul">-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304040','锦江区','359040','锦江区市场监管局')">锦江区市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304050','青羊区','359050','青羊区市场监管局')">青羊区市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304060','金牛区','359060','金牛区市场监督管理局')">金牛区市场监督管理局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304070','武侯区','359070','武侯区市场监管局')">武侯区市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304080','成华区','359080','成华区工商局')">成华区工商局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304120','龙泉驿区','359120','龙泉驿区工商局')">龙泉驿区工商局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304130','青白江区','359130','青白江区工商局')">青白江区工商局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304140','新都区','363140','新都区市场监管局')">新都区市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304150','温江区','359150','温江区市场监管局')">温江区工商局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304210','金堂县','359210','金堂县工商局')">金堂县工商局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304220','双流县','359220','双流县市场监管局')">双流县市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304240','郫县','363240','郫县市场监督管理局')">郫县市场监督管理局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304290','大邑县','359290','大邑县工商局')">大邑县工商局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304310','蒲江县','359310','蒲江县市场监督管理局')">蒲江县市场监督管理局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304320','新津县','363320','新津县市场监管局')">新津县市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304810','都江堰市','363810','都江堰市市场监督管理局')">都江堰市市场监督管理局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304820','彭州市','359820','彭州市市场监管局')">彭州市市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304830','邛崃市','359830','邛崃市市场监管局')">邛崃市市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304840','崇州市','359840','崇州市市场监管局')">崇州市市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304090','高新区','359090','高新区工商局')">高新区工商局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304910','天府新区','301910876','天府新区城市管理和市场监管局')">天府新区城市管理和市场监管局</li>-->
<!--                            </ul>-->
<!--                        </div>-->
<!--                        <div id="menu4" class="tab-pane fade deptTransfer-content">-->
<!--                            <ul class="deptTransfer-ul">-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304040','锦江区','359040','锦江区市场监管局')">锦江区市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304050','青羊区','359050','青羊区市场监管局')">青羊区市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304060','金牛区','359060','金牛区市场监督管理局')">金牛区市场监督管理局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304070','武侯区','359070','武侯区市场监管局')">武侯区市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304080','成华区','359080','成华区市场监督管理局')">成华区市场监督管理局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304120','龙泉驿区','363120','龙泉驿区食药监局')">龙泉驿区食药监局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304130','青白江区','363130','青白江区食药监局')">青白江区食药监局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304140','新都区','363140','新都区市场监管局')">新都区市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304150','温江区','359150','温江区市场监管局')">温江区市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304210','金堂县','363210','金堂县食药监局')">金堂县食药监局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304220','双流县','359220','双流县市场监管局')">双流县市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304240','郫县','363240','郫县市场监督管理局')">郫县市场监督管理局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304290','大邑县','363290','大邑县食药监局')">大邑县食药监局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304310','蒲江县','359310','蒲江县市场监督管理局')">蒲江县市场监督管理局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304320','新津县','363320','新津县市场监管局')">新津县市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304810','都江堰市','363810','都江堰市市场监督管理局')">都江堰市市场监督管理局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304820','彭州市','359820','彭州市市场监管局')">彭州市食药监局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304830','邛崃市','359830','邛崃市市场监管局')">邛崃市市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304840','崇州市','359840','崇州市市场监管局')">崇州市市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304090','高新区','363090','高新区食药监局')">高新区食药监局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304910','天府新区','301910876','天府新区城市管理和市场监管局')">天府新区城市管理和市场监管局</li>-->
<!--                            </ul>-->
<!--                        </div>-->
<!--                        <div id="menu5" class="tab-pane fade deptTransfer-content">-->
<!--                            <ul class="deptTransfer-ul">-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304040','锦江区','335040','锦江区城管局')">锦江区城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304050','青羊区','335050','青羊区城管局')">青羊区城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304060','金牛区','335060','金牛区城管局')">金牛区城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304070','武侯区','335070','武侯区城管局')">武侯区城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304080','成华区','335080','成华区城管局')">成华区城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304120','龙泉驿区','335120','龙泉驿区城管局')">龙泉驿区城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304130','青白江区','335130','青白江区城管局')">青白江区城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304140','新都区','335140','新都区城管局')">新都区城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304150','温江区','335150','温江区城管局')">温江区城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304210','金堂县','335210','金堂县城管局')">金堂县城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304220','双流县','335220','双流县城管局')">双流县城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304240','郫县','335240','郫县城管局')">郫县城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304290','大邑县','335290','大邑县城管局')">大邑县城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304310','蒲江县','335310','蒲江县城管局')">蒲江县城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304320','新津县','335320','新津县城管局')">新津县城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304810','都江堰市','335810','都江堰市城管局')">都江堰市城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304820','彭州市','335820','彭州市城管局')">彭州市城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304090','高新区','335090','高新区城管局')">高新区城管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304910','天府新区','301910876','天府新区城市管理和市场监管局')">天府新区城市管理和市场监管局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304840','崇州市','335840','崇州市城管局')">崇州市城管局</li>-->
<!--                            </ul>-->
<!--                        </div>-->
<!--                        <div id="menu6" class="tab-pane fade deptTransfer-content">-->
<!--                            <ul class="deptTransfer-ul">-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304040','锦江区','373040','锦江区旅游局')">锦江区旅游局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304050','青羊区','301050804','青羊区文体旅局')">青羊区文体旅局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304060','金牛区','301060810','金牛区文化旅游和体育局')">金牛区文化旅游和体育局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304070','武侯区','301070807','武侯区文体局')">武侯区文体局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304080','成华区','301080804','成华区文旅体局')">成华区文旅体局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304120','龙泉驿区','301120828','龙泉驿区文旅局')">龙泉驿区文旅局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304130','青白江区','301130807','青白江区旅发局')">青白江区旅发局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304140','新都区','301140801','新都区商务和旅游局')">新都区商务和旅游局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304150','温江区','373150','温江区旅游局')">温江区旅游局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304210','金堂县','373210','金堂县旅游局')">金堂县旅游局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304220','双流县','301220834','双流县文旅局')">双流县文旅局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304240','郫县','301240813','郫县文旅体广新局')">郫县文旅体广新局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304290','大邑县','373290','大邑县旅游局')">大邑县旅游局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304310','蒲江县','373310','蒲江县旅游局')">蒲江县旅游局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304320','新津县','373320','新津县旅游局')">新津县旅游局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304810','都江堰市','373810','都江堰市旅游局')">都江堰市旅游局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304820','彭州市','301820858','彭州市文广旅局')">彭州市文广旅局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304830','邛崃市','301830825','邛崃市文广新局')">邛崃市文广新局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304840','崇州市','301840804','崇州市文体广新局')">崇州市文体广新局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304090','高新区','301090804','高新区社事局')">高新区社事局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304910','天府新区','301910810','天府新区科技宣传局')">天府新区科技宣传局</li>-->
<!--                                <li class="deptTransfer-li" ondblclick="DirectDept('304840','崇州市','301840861','崇州市综合行政执法局')">崇州市综合行政执法局</li>-->
<!--                            </ul>-->


<!--                        </div>-->
                    </div>
                </div>
                <div class="col-sm-3">
                    <div class="col-sm-12" style="margin-top: 45px">
                        <div class="input-group">
                            <input type="text" class="form-control" id="tags" value=""
                                   style="border-radius: 5px 0 0 5px;"/>
                            <span class="input-group-addon" onclick="deptSearch()"><i class="glyphicon glyphicon-search"></i></span>
                        </div>
                    </div>
                    <div class="col-sm-12" style="margin-top: 45px">
                        <!--                    <span class="badge badge-success" style="margin-bottom: 10px">双击取消选中</span>-->
                        <div class="alert alert-info alert-dismissable">
                            双击取消选中
                        </div>
                        <select id="selectDept" class="form-control" multiple="multiple" style="height: 162px"></select>
                    </div>
                    <div class="col-sm-12" style="margin-top: 45px;text-align: center">
                        <button type="button" class="btn btn-success btn-sm" onclick="ReportDept()">确认</button>
                    </div>
                </div>
        </div>
    </form>
</div>


<script th:src="@{/ajax/libs/layui/laydate.js}"></script>
<th:block th:include="include :: footer"/>
<script th:src="@{/ajax/libs/bootstrap-tagsinput/tagsinput.min.js}"></script>
<script th:src="@{/ajax/libs/jQuery-ui/jquery-ui.js}"></script>
<script th:src="@{/js/deptTransfer.js}"></script>
<script>
    function SelectDept(dNo,dName){
        var opt = $("#selectDept").find('option[value='+dNo+']');
        if(opt.length > 0){
            return
        }else{
            $('#selectDept').append('<option ondblclick="$(this).remove()" value="'+dNo+'">'+dName+'</option>')
        }
    }

    function DirectDept(sdeptNo,sdeptName,dNo,dName){
        var opt = $("#selectDept").find('option[value='+dNo+']');
        if(opt.length > 0){
            return
        }else{
            $('#selectDept').append('<option ondblclick="$(this).remove()" data-sdeptNo="'+sdeptNo+'" data-sdeptName="'+sdeptName+'" value="'+dNo+'">'+dName+'</option>')
        }
    }

    function ReportDept() {
        //获取选中的部门
        var deptOps = $('#selectDept').find('option');
        var dno = '',dname = '',sdno = '',sdname = '';
        $.each(deptOps,function(index,value){
            if(index !== 0){
                dno += ",";
                dname += ","
            }
            dno += $(value).val();
            dname += value.innerText;
        })

        //判断当前tab是否属于直派
        var isDirect = false;
        if($('div.active.in').attr('id').substr(0,3) > 2){
            isDirect = true;
            $.each(deptOps,function(index,value){
                if(index !== 0){
                    sdno += ",";
                    sdname += ","
                }
                sdno += $(value).attr("data-sdeptNo");
                sdname += $(value).attr("data-sdeptName");
            })
        }

        var parentDialog = $(top.window['deptdialog']).find('iframe')[0].contentWindow;
        try{
            if(isDirect){
                if(parentDialog.SonDirectSingle && typeof(parentDialog.SonDirectSingle)=="function"){
                    parentDialog.SonDirectSingle(sdno,sdname,dno,dname);
                }
                else{
                    parentDialog.document.getElementById('navFrame').contentWindow.SonDirectSingle(sdno,sdname,dno,dname);
                }
            }else{
                if(parentDialog.SonBackSingle && typeof(parentDialog.SonBackSingle)=="function"){
                    parentDialog.SonBackSingle(dno,dname);
                }
                else{
                    parentDialog.document.getElementById('navFrame').contentWindow.SonBackSingle(dno,dname);
                }
            }
        }
        catch(exception){
            alert(exception);
        }
        $.modal.close();
    }

    function deptSearch(){
        var list = $('div.active.in').find('li');
        var searchVal = $('#tags').val();
        $.each(list,function(index,value){
            var val = $(value).text();
            var item = $(list[index]);
            if(searchVal === ''){
                item.show();
            }else if(val.indexOf(searchVal) === -1){
                item.hide();
            }else{
                item.show();
            }
        })
        var isShow = true;
        $.each(list,function(index,value){
            var item = $(list[index]);
            if (item.is(':visible')){
                isShow = false;
            }
        })
        if (isShow) {
            if($(list[0]).text() !== '未查询到匹配数据') {
                var oldHtml = $('div.active.in').find('ul').html();
                $('div.active.in').find('ul').html('<li class="deptTransfer-li">未查询到匹配数据</li>' + oldHtml);
            }else {
                $(list[0]).show()
            }
        }else if($(list[0]).text() === '未查询到匹配数据'){
            $(list[0]).hide()
        }
    }

    $(function(){
        var list = $('.nav-tabs').find('li');
        for (var i = 0; i < list.length; i++) {
            $('#tab'+(i+1)).bind('click',function() {
                menuChange(this);
            })
        }
    })

    function menuChange(obj){
        var menuId = $(obj).attr('href').substring(1);
        var menuList = $('#'+menuId).find('li');
        $.each(menuList,function (index,value) {
            var item = $(menuList[index]);
            if($(value).text() == '未查询到匹配数据'){
                item.hide();
            }else{
                item.show();
            }
        });
        $('#tags').val('');
    }
</script>
</body>
</html>

